package com.it.dao.annototion;

import com.it.pojo.User;
import org.junit.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration//等价于xml配置文件
@ComponentScan(basePackages = {"com.it"})//等价于<context:component-scan base-package="com.itheima"/>
@PropertySource(value = {"classpath:bean.properties"},encoding = "utf-8")//等价于<context:property-placeholder location="classpath:bean.properties" file-encoding="UTF-8"/>
public class AnnototionTest {


    /**
     @Bean作用：
      *  将方法下返回的对象作为一个bean被ioc容器管理
      *      默认bean的名称为方法的名称
     * @return
     */
    @Bean("user")
    public User myUser() {
        User user = new User();
        user.setUserName("xiaxin");
        user.setAge(18);
        return user;
    }

}
